import {
  BoxingOne,
  Code,
  FileDoc,
  FilePdf,
  FileText,
  FolderOpen,
  Music,
  Pic,
  VideoOne,
} from '@icon-park/vue-next';

// 获取文件图标组件
export const getFileIconComponent = (filename: string) => {
  const ext = filename.split('.').pop()?.toLowerCase();
  switch (ext) {
    case '7z':
    case 'gz':
    case 'rar':
    case 'tar':
    case 'zip': {
      return FileDoc;
    }
    case 'avi':
    case 'mkv':
    case 'mov':
    case 'mp4':
    case 'webm': {
      return VideoOne;
    }
    case 'css':
    case 'html':
    case 'js':
    case 'json':
    case 'ts':
    case 'vue': {
      return Code;
    }
    case 'doc':
    case 'docx': {
      return FileText;
    }
    case 'flac':
    case 'mp3':
    case 'ogg':
    case 'wav': {
      return Music;
    }
    case 'gif':
    case 'jpeg':
    case 'jpg':
    case 'png':
    case 'svg':
    case 'webp': {
      return Pic;
    }
    case 'md':
    case 'txt': {
      return FileText;
    }
    case 'pdf': {
      return FileDoc;
    }
    default: {
      return FolderOpen;
    }
  }
};
export const getFileIcon = (
  filename: string | undefined,
  size: number = 30,
) => {
  if (!filename) {
    return <FolderOpen size={size} />;
  }
  const ext = filename.split('.').pop()?.toLowerCase();
  switch (ext) {
    case 'avi':
    case 'mov':
    case 'mp4': {
      return <VideoOne size={size} />;
    }
    case 'doc':
    case 'docx': {
      return <FileDoc size={size} />;
    }
    case 'gif':
    case 'jpeg':
    case 'jpg':
    case 'png': {
      return <Pic size={size} />;
    }
    case 'mp3':
    case 'wav': {
      return <Music size={size} />;
    }
    case 'pdf': {
      return <FilePdf size={size} />;
    }
    case 'rar':
    case 'zip': {
      return <BoxingOne size={size} />;
    }
    default: {
      return <FolderOpen size={size} />;
    }
  }
};

// 获取文件分类
export const getFileCategory = (ext: string): string => {
  switch (ext) {
    case 'avi':
    case 'mov':
    case 'mp4': {
      return '视频';
    }
    case 'doc':
    case 'docx': {
      return '文档';
    }
    case 'gif':
    case 'jpeg':
    case 'jpg':
    case 'png': {
      return '图片';
    }
    case 'pdf': {
      return '文档';
    }
    case 'rar':
    case 'zip': {
      return '压缩包';
    }
    default: {
      return '其他';
    }
  }
};
